Skip to content

Conversation

@kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Nov 4, 2025

this PR implements a connectivity detector that performs a HEAD request to the notices endpoint, with a timeout of 1 hour. before making any subsequent network calls, (including GET notices and PUT telemetry) we check to see if we have already determined the network to be disconnected. in those cases, we skip subsequent calls.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

// Check connectivity before attempting network request
const hasConnectivity = await NetworkDetector.hasConnectivity(this.agent);
if (!hasConnectivity) {
throw new ToolkitError('No internet connectivity detected');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is throwing the right thing here? Is that error caught elsewhere? Asking because Notices should just silently fail. A comment might help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the right thing to do here. we are throwing errors in web-data-source on failures and expecting to swallow them elsewhere (which we do)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking] Since this pattern will be very common (get the result, check whether it's true and throw an error if not), we could also have a method that takes a callback and does this for you:

return NetworkDetector.ifConnected(async() => {...});

);
});

test('skips request when no connectivity detected', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the true result: we do not ping the telemetry endpoint in environments without internet access

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.50%. Comparing base (8758f3c) to head (c33ec6c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #926      +/-   ##
==========================================
+ Coverage   84.17%   84.50%   +0.33%     
==========================================
  Files          71       71              
  Lines       10437    10444       +7     
  Branches     1334     1349      +15     
==========================================
+ Hits         8785     8826      +41     
+ Misses       1611     1577      -34     
  Partials       41       41              
Flag Coverage Δ
suite.unit 84.50% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
@kaizencc kaizencc deployed to integ-approval November 14, 2025 00:19 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants